/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interfaz;

import javax.swing.JOptionPane;

/**
 *
 * @author Duvan
 */
public class Searching extends javax.swing.JFrame {

    /**
     * Creates new form Searching
     */
    public Searching() {
        initComponents();
    }
    
    
    //Variable del tipo de busqueda a Editar
    private String tipeToEdit;

    public void setTipeToEdit(String tipeToEdit) {
        this.tipeToEdit = tipeToEdit;
    }
    
    //Variables
    private String Buscar;
    private EditionMovie newMovie;
    private EditionPerson newActor, newArtist;
    private EditionSong newSong;
    
    //Metodo para elegir que tipo de edicion se realizara (Boton Search)
    public void tipeToEdit(String tipe){
        switch (tipe) {
            case "movie":
                editMovie();
                break;
            case "actor":
                editActor();
                break;
            case "song":
                editSong();
                break;
            case "artist":
                editArtist();
                break;
        }
    }
    
    //Metodo para Editar Actores
    public void editActor(){
        Buscar = SearchEdit.getText();
  
        //Variables de prueba
        String PruebaBusqueda = "Duvan";
        
        if (Buscar.equals(PruebaBusqueda)){
           newActor = new EditionPerson();
           newActor.setVisible(true);
           this.dispose();
        }
        else{
           JOptionPane.showMessageDialog(null,"Sin Resultados"); 
        }
    }
    
    
    //Metodo para editar Peliculas
    public void editMovie(){
        Buscar = SearchEdit.getText();
  
        //Variables de prueba
        String PruebaBusqueda = "Superman";
        
        if (Buscar.equals(PruebaBusqueda)){
           newMovie = new EditionMovie();
           newMovie.setVisible(true);
           this.dispose();
        }
        else{
           JOptionPane.showMessageDialog(null,"Sin Resultados"); 
        }
    }
    
    
    //Metodo para editar Canciones
    public void editSong(){
        Buscar = SearchEdit.getText();
  
        //Variables de prueba
        String PruebaBusqueda = "eu si te pego";
        
        if (Buscar.equals(PruebaBusqueda)){
           newSong = new EditionSong();
           newSong.setVisible(true);
           this.dispose();
        }
        else{
           JOptionPane.showMessageDialog(null,"Sin Resultados"); 
        }
    }
    
    
    //Metodo para editar Artistas
    public void editArtist(){
        Buscar = SearchEdit.getText();
  
        //Variables de prueba
        String PruebaBusqueda = "Duvan";
        
        if (Buscar.equals(PruebaBusqueda)){
           newArtist = new EditionPerson();
           newArtist.setVisible(true);
           this.dispose();
        }
        else{
           JOptionPane.showMessageDialog(null,"Sin Resultados"); 
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Search = new javax.swing.JButton();
        SearchEdit = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Search");
        setResizable(false);

        Search.setText("Search");
        Search.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(46, Short.MAX_VALUE)
                .addComponent(SearchEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(33, 33, 33)
                .addComponent(Search)
                .addGap(37, 37, 37))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Search)
                    .addComponent(SearchEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchActionPerformed
        tipeToEdit(tipeToEdit);
    }//GEN-LAST:event_SearchActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Searching.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Searching.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Searching.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Searching.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Searching().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Search;
    private javax.swing.JTextField SearchEdit;
    // End of variables declaration//GEN-END:variables
}
